package org.andes.kownledge;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

import org.armedbear.lisp.LispObject;

/**
 * Created by IntelliJ IDEA.
 * User: wenfeix
 * Date: Feb 11, 2011
 * Time: 10:11:28 AM
 * To change this template use File | Settings | File Templates.
 */
public class operator {
	
	/*(defstruct (operator (:print-function print-operator))
	  name             //Unique Operator name.
	  arguments        //List of operator arguments for use in defining the operator s-expression.
	  preconditions    //The preconditions for this operator to occur.

	  effects          //The operator's effects.
	  hint             //The hint field.
	  HintVars         // Argument elements used to compare two opapps at help time for use by 
	                   // the comparison system.  
	  
	  specifications   //The operaor specifications.

	  Variables        //A list consisting of all the variables in this operator.
	  
	  Features         //A list of operator features e.g. PSM, and Ordered which
	                   //are used to determine aspects of the operator.
	  
	  (CogLoad 1 :type real)      //The 'cognitive load' of this operator used for min searching.
	                              // Needs to be edded into the loop.

	  order           ;List of dotted pairs giving order specifications
			  ;when several operators apply choose those with maximal order 
	  )*/

  private String name;             //Unique Operator name.
  public String name(){
	  return name;
  }
  public void setName(String name){
	  this.name=name;
  }
  private String arguments;        //List of operator arguments for use in defining the operator s-expression.
  public String arguments(){
	  return arguments;
  }
  private Stack<LispObject> preconditions=new Stack<LispObject>();    //The preconditions for this operator to occur.

  public Stack<LispObject> preconditions(){
	  return preconditions;
  }
  public void setPreconditions(Stack<LispObject> pres){
	  preconditions=pres;
  }
  private List<LispObject> effects=new ArrayList<LispObject>();          //The operator's effects.
  public List<LispObject> effects(){
	  return effects;
  }
  private String hint;             //The hint field.
  private String HintVars;         // Argument elements used to compare two opapps at help time for use by
                   // the comparison system.

  private String specifications;   //The operaor specifications.

  private List<LispObject> Variables;        //A list consisting of all the variables in this operator.

  private List<String> Features;         //A list of operator features e.g. PSM, and Ordered which
                   //are used to determine aspects of the operator.

  //(CogLoad 1 :type real)      //The 'cognitive load' of this operator used for min searching.
                              // Needs to be edded into the loop.

  int order;           //List of dotted pairs giving order specifications
		              //when several operators apply choose those with maximal order
  ;






    //////////////////////////////////////////////////////////////////////////;
// get-operator-variables
// Obtain a list of all the unique variables in this operator.
// When the operator is defined this list is used to initialize the
// Variables field.
//
// Arguments: Op: The operator to be polled.
// Returns:  A unique list of all unique variables in the operator.

/*(defun get-operator-variables (Op)
  "Obtain a list of all variables in this operator."
  (remove-duplicates                                             //Cull the copies from the results and return.
   (append (Operator-arguments Op)
	   (variables-in (Operator-preconditions op))
	   (variables-in (Operator-Effects Op)))))*/
    public List<LispObject> Variables(){
    	return Variables;
    }


/*(defun get-operator-hintvars (Op)
  "Obtain a list of all variables in this operator."
  (remove-duplicates                                             //Cull the copies from the results and return.
   (append (Operator-arguments Op)
	   (variables-in (Operator-hint OP)))))*/
    public void getHintvars(){

    }


/*(defun bind-operator-vars (op vals)
  "Match the operator with the values."
  (or (if (null vals) no-bindings)
      (unify (operator-variables op) vals)
      (unless  (and (null vals) (null (operator-variables op)))
	(format t "Operator variables don't match operator values: ~a~%    May need to regenerate problem file.~%    operator-variables:  ~A~%    values:  ~A~%"
		(operator-name op) (operator-variables op) vals)
	nil)))*/
    public void bindVars(){

    }
    
    
    
    //-----------------------------------------------------------------------------
    // Operator-var-copy (public)
    // In order to avoid unconcious overwriting and to permit recursion this 
    // function systematically replaces all variables in an operator with a 
    // matching renamed set.

//    (defun operator-var-copy (Operator)
//      "Obtain a copy of Op with the vars changed."
//
//      (let* ((Op (copy-Operator Operator))
//    	 (oplist (list (Operator-arguments Op)         //Generate a single expression of the operator.
//    		       (Operator-Preconditions Op)
//    		       (Operator-Effects Op)
//    		       (Operator-Variables Op)
//    		       (Operator-hintvars Op))))
//        
//        (setq oplist (rename-variables oplist))            //replace all the variables with new vars.
//        (setf (operator-arguments Op) (nth 0 Oplist))      //Set the new Operator-arguments.
//        (setf (operator-preconditions Op) (nth 1 Oplist))  //Set the new preconditions.
//        (setf (operator-effects Op) (nth 2 Oplist))        //set the new effects.
//        (setf (Operator-Variables Op) (nth 3 Oplist))
//        (setf (Operator-hintvars Op) (nth 4 Oplist))
//        Op))     
    public operator operator_var_copy(){
    	return this;
    }
        
        
        
}
